package com.arlen.centre.service.impl;

import com.arlen.centre.exceptionHandle.WxException;
import com.arlen.centre.service.EventService;
import com.arlen.commom.constant.EventConstant;
import com.arlen.commom.vo.PicSysPhoto;
import com.arlen.commom.vo.TextMessage;
import com.thoughtworks.xstream.XStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class EventServiceImpl implements EventService {
    @Autowired

    private static final Logger logger = LoggerFactory.getLogger(EventServiceImpl.class);

    @Override
    public <T>T analysisEvent(Map mesMao) { //暂为统一实体类的规范
        String event = mesMao.get("Event").toString();
        XStream xStream = new XStream();
        if (event.equals(EventConstant.CLICK.getEvent())){
            TextMessage textMessage = new TextMessage(mesMao);
            textMessage.setContent("https://gitee.com/TIDUDADA/wx-accounts 源码地址希望可以一起改进"); //todo 点击事件
            textMessage.setMsgType("text");
            xStream.processAnnotations(TextMessage.class);
            String toXML = xStream.toXML(textMessage);
            return (T)toXML;
        }else if (EventConstant.PIC_SYSPHOTO.getEvent().equals(event)){
            PicSysPhoto picSysPhoto = new PicSysPhoto(mesMao);


        }

        logger.error(this+""+"暂未功能");
        throw new WxException("event is Exception");

    }
}
